package collection;

import java.io.File;
import java.io.FileFilter;

public class ListFilesDemo2 {
    public static void main(String[] args) {
        //获取当前项目目录中名字以""TEST"开头的文件
       /* File dir=new File(".");
        FileFilter filter=new FileFilter() {
            public boolean accept(File file) {
                String name=file.getName();
                return name.startsWith("tset");
            }
        };
        File[]subs=dir.listFiles(filter);
        for (File sub:subs){
            System.out.println(sub.getName());
        }*/
        File dir = new File(".");
        FileFilter filter = new FileFilter() {
            @Override
            public boolean accept(File file) {
                String name = file.getName();
                return name.endsWith(".txt");
            }

        };
        File[]subs=dir.listFiles(filter);
        for (File sub:subs){
            System.out.println(sub.getName());
        }

    }}
